class SolutionNode extends MyNode{
    constructor($state='new',...obj){
        super('Solution',$state,{
            name:"方案名称",
            solution:'解决方案',
            frequency:{},
            reasonFrequency:{}
        },...obj);
        delete this.frequency["undefined"];
        delete this.reasonFrequency["undefined"];
    }

    getText(){
        return `方案：${this.name}`;
    }

    defaultFrequency(featureId){
        this.frequency = this.frequency || {};
        if (!this.frequency[`${featureId}`]){
            this.frequency[`${featureId}`] = 0
        }
        return this.frequency;
    }

    defaultReasonFrequency(reasonId){
        this.reasonFrequency = this.reasonFrequency || {};
        if (!this.reasonFrequency[`${reasonId}`]){
            this.reasonFrequency[`${reasonId}`] = 0
        }
        return this.reasonFrequency;
    }

    getTemplate(edge,g){
        return `
 <div class="form-group">
    <label class="col-sm-2 control-label">方案名称</label>
    <div class="col-sm-10">
    <input data-ng-model-options="{updateOn:'default blur',debounce:{default:5000,blur:0}}" type="text" class="form-control" data-ng-model="graph.getNode('${this.id}').name" placeholder="方案名称">
    </div>
 </div>
 <div class="form-group">
    <label class="col-sm-2 control-label">解决方案</label>
    <div class="col-sm-10">
    <textarea data-ng-model-options="{updateOn:'default blur',debounce:{default:5000,blur:0}}" rows="3" class="col-sm-10 form-control" data-ng-model="graph.getNode('${this.id}').solution" placeholder="请输入解决方案"></textarea>
    </div>
 </div>
 <div class="form-group">
    <label class="col-sm-2 control-label">设置原因到方案的置信度</label>
    <div class="col-sm-10">
    <input  ng-init="graph.getNode('${this.id}').reasonFrequency = graph.getNode('${this.id}').defaultReasonFrequency('${g.getLink(edge).from}');"
          ng-model="graph.getNode('${this.id}').reasonFrequency['${g.getLink(edge).from}']" 
          data-ng-model-options="{updateOn:'default blur',debounce:{default:5000,blur:0}}">
    </div>
</div>
  <div class="form-group">
 <label class="col-sm-2 control-label">操作</label>
 <p class="col-sm-10 form-control-static">
        <a class="button btn" data-ng-click="attachTool('${this.id}')">添加工具</a>
        <a class="button btn"  data-ng-click="attachMaterial('${this.id}')">添加材料</a>
        <a class="button btn" data-ng-if="allowFeature('${this.id}')" data-ng-click="attachFeature('${this.id}')">添加特征</a>
     <a class="button btn" data-ng-if="allowFeature('${this.id}')" data-ng-click="attachGroup('${this.id}','FeatureGroup')">添加特征组</a>
     <a class="button btn" data-ng-if="allowFeature('${this.id}')" data-ng-click="attachExternalFeature('${this.id}')">添加已存在特征</a>
     <a class="button btn" data-ng-if="allowFeature('${this.id}')" data-ng-click="attachExternalGroup('${this.id}','FeatureGroup')">添加已存在特征组</a>
     &nbsp;<a class="btn" href="javascript:;" ng-click="removeEdge(${edge})">删除当前节点</a>
 </p>
</div>
`;
    }

    getReadonlyTemplate(edge,g){
        return `
<div class="form-group">
    <label class="col-sm-2 control-label">方案名称</label>
    <p class="col-sm-10 form-control-static">${this.name}</p>
 </div>
 <div class="form-group">
    <label class="col-sm-2 control-label">解决方案</label>
    <p class="col-sm-10 form-control-static">${this.solution}</p>
 </div>
`
    }
}
